/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sourcery;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.*;

/**
 *
 * @author claire
 */
public class MainFrame extends JFrame {
    private MainPanel panel;
    private JMenuBar menuBar;
    private JMenu fileMenu;
    private JMenu nodeTypesMenu;
    private JMenu relationTypesMenu;

    public MainFrame() {
        super("MainFrame");
        setBounds(0, 0, 800, 800);
        setBackground(Color.BLACK);



        panel = new MainPanel();
        panel.setBackground(Color.BLACK);
        add(panel, BorderLayout.CENTER);


        menuBar = new JMenuBar();
            fileMenu = new JMenu("File");
                fileMenu.setMnemonic(KeyEvent.VK_F);
                JMenuItem item = new JMenuItem("Save", KeyEvent.VK_S);
                    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
                    item.addActionListener(
                        new ActionListener() {
                            public void actionPerformed(ActionEvent e)
                            {panel.save();}
                        }
                    );
                fileMenu.add(item);
                item = new JMenuItem("Load", KeyEvent.VK_L);
                    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK));
                    item.addActionListener(
                        new ActionListener() {
                            public void actionPerformed(ActionEvent e)
                            {panel.load();}
                        }
                    );
                fileMenu.add(item);
                fileMenu.addSeparator();
                item = new JMenuItem("Save & Quit", KeyEvent.VK_W);
                    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
                    item.addActionListener(
                        new ActionListener() {
                            public void actionPerformed(ActionEvent e)
                            {panel.save(); System.exit(0);}
                        }
                    );
                fileMenu.add(item);
                item = new JMenuItem("Quit", KeyEvent.VK_Q);
                    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
                    item.addActionListener(
                        new ActionListener() {
                            public void actionPerformed(ActionEvent e)
                            {System.exit(0);}
                        }
                    );
                fileMenu.add(item);
            menuBar.add(fileMenu);

            nodeTypesMenu = new JMenu("Nodes");
                nodeTypesMenu.setMnemonic(KeyEvent.VK_N);
                item = new JMenuItem("Edit Node Types...", KeyEvent.VK_E);
                    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
                    item.addActionListener(
                        new ActionListener() {
                                public void actionPerformed(ActionEvent e)
                                {panel.editNodes();}
                        }
                    );
                nodeTypesMenu.add(item);
            menuBar.add(nodeTypesMenu);
            
            relationTypesMenu = new JMenu("Relationships");
                relationTypesMenu.setMnemonic(KeyEvent.VK_R);
                item = new JMenuItem("Edit Relation Types...", KeyEvent.VK_E);
                    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
                    item.addActionListener(
                        new ActionListener() {
                                public void actionPerformed(ActionEvent e)
                                {panel.editRelations();}
                        }
                    );
                relationTypesMenu.add(item);
            menuBar.add(relationTypesMenu);


        add(menuBar,BorderLayout.NORTH);

        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new MainFrame();
    }

}
